///////////////////////////////////////////////////////////////////////////////
// Filename: network.h
// Purpose: Provide a framework for winsock2
// Created by: Shane Laffond
// Contact info: slaffond1990@gmail.com
//
// Bugs:
//		None
// Todo:
//		Add server client buffer ( push clients onto vector stack on acceptConn
//		accpet has wparam equal to server
//		send give garbage
///////////////////////////////////////////////////////////////////////////////

#pragma once
#include <winsock2.h>
#include "log.h"

const USHORT default_port = 7212; // Ava b-day
extern HWND gWindow;

const int WM_SOCKET = 1004; // for allowing into windows proc

const unsigned int server_flags = FD_CLOSE | FD_ACCEPT | FD_READ; // read, accept, with possible connect message

const unsigned int client_flags = FD_CLOSE | FD_READ | FD_WRITE; // read and write client

const unsigned int client_ro_flags = FD_CLOSE | FD_READ;	// Read only client

class phatIP
{
private:
	WSADATA wsaData;
	sockaddr_in mAddr0;
public:

	SOCKET mServer0;
	SOCKET mClient0;
	phatIP();
	~phatIP();

	void openServer();
	void closeServer();

	void connectSocket( SOCKET &sSocket, USHORT uPort = default_port, UINT iMode = 1, UINT iFlags = client_flags );
	void closeSocket( SOCKET &sSocket );

	void acceptConn( SOCKET &sSocket );
	// Accessors

	
};

void Send( SOCKET &sSocket, string sBuffer, int iSize = 0 );
